# Author    : CoffeeChicken
# Date      : 2020-10-04 12:21
# Function  : 演示 破解百度翻译

import requests
import json

headers = {
    'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) "
                  "Chrome/85.0.4183.121 Safari/537.36"
}

url = "https://fanyi.baidu.com/sug"

param = {
    "kw": "dog"
}
# 直接发起请求会被网站劫持, 需要加上伪装
response = requests.get(url=url, params=param, headers=headers)
# 将Json字符串转换为字典
result_dict = json.loads(response.text)

print(result_dict)

# 保存json
fp = open("dog.json", "w", encoding="utf-8")
json.dump(response.json(), fp=fp, ensure_ascii=False)
